#include <bits/stdc++.h>
using namespace std;
int clip[21][21];
int pm[450];
bool prime[100001];
void shai(){
    int cnt=1;
    for(int i=2;i <= 100000;i++){
        if (!prime[i]){
            pm[cnt++]=i;
            for (int j=i;j<=100000;j+=i){
                prime[j]=true;
            }
        }
    }
}
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    shai();
    int left = 0, top = 0, right = n - 1, bottom = n - 1;
    int l, r, b, t;
    int num = 1;
    while (num <= n * n) {
        l = left;
        while (l <= right)
            clip[top][l++] = pm[num++];
        ++top;
        t = top;
        while (t <= bottom)
            clip[t++][right] = pm[num++];
        --right;
        r = right;
        while (r >= left)
            clip[bottom][r--] = pm[num++];
        --bottom;
        b = bottom;
        while (b >= top)
            clip[b--][left] = pm[num++];
        ++left;
    }
        
        
    cout<<clip[x-1][y-1];
    return 0;
}
